define(['d3'], function(d3) {
  function panAndZoom(svg, g, callback) {
    var zoom = d3
      .zoom()
      .scaleExtent([1 / 8, 8])
      .on('zoom', () => {
        let {transform} = d3.event
        g.attr(
          'transform',
          `translate(${transform.x},${transform.y}) scale(${transform.k})`
        )
        callback && callback('move')
      })
      .on('end', () => {
        callback && callback('end')
      })
    svg
      .call(zoom)
      .on('dblclick.zoom', null)
      // .on('wheel.zoom', null)
    return zoom;
  }

  return panAndZoom;
})